package tech.com.commoncore.base;

import android.os.Build;
import android.view.WindowManager;

import com.aries.ui.view.title.TitleBarView;

import tech.com.commoncore.R;
import tech.com.commoncore.SystemBarTintManager;
import tech.com.commoncore.delegate.BaseTitleDelegate;
import tech.com.commoncore.interf.IBaseTitleView;

/**
 * @Author: AriesHoo on 2018/7/23 10:35
 * @E-Mail: AriesHoo@126.com
 * Function: 包含TitleBarView的Activity
 * Description:
 */
public abstract class BaseTitleActivity extends BaseActivity implements IBaseTitleView {

    protected BaseTitleDelegate mBaseTitleDelegate;
    protected TitleBarView mTitleBar;

    @Override
    public void beforeSetTitleBar(TitleBarView titleBar) {
        titleBar.setRightText("")
                .setLeftTextDrawable(R.mipmap.back_white)
                .setTitleMainText("")
                .setDividerVisible(false)
                .setDividerHeight(0)
                .setStatusBarLightMode(false);
//        setSystemBarTintManager();
    }

    @Override
    public void beforeInitView() {
        super.beforeInitView();
        mBaseTitleDelegate = new BaseTitleDelegate(mContentView, this, this.getClass());
        mTitleBar = mBaseTitleDelegate.mTitleBar;
    }


    //设置状态栏，底部虚拟控件颜色
    private void setSystemBarTintManager() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            //透明状态栏
            //getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //透明导航栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            SystemBarTintManager tintManager = new SystemBarTintManager(this);
            // 激活状态栏
            tintManager.setStatusBarTintEnabled(true);
            // enable navigation bar tint 激活导航栏
            tintManager.setNavigationBarTintEnabled(true);
            //设置系统栏设置颜色
//            tintManager.setTintColor(R.color.marker_color);
            //给状态栏设置颜色
            tintManager.setStatusBarTintResource(tech.com.commoncore.R.color.colorPrimary);
            //给导航栏设置资源
            tintManager.setNavigationBarTintResource(tech.com.commoncore.R.color.bottom_bar);
        }
    }

}
